Skip to content

[Master]-Inconsistent Validation of Non-Deductible VAT % for Purchase Lines Sharing the Same VAT Identifier - #10521

Open
neeleshsinghal wants to merge 3 commits into
mainfrom
bugs/Bug-647053-NonDeductible-VAT-Purch-Lines-Same-VAT-Identifier-v4
Open

[Master]-Inconsistent Validation of Non-Deductible VAT % for Purchase Lines Sharing the Same VAT Identifier#10521
neeleshsinghal wants to merge 3 commits into
mainfrom
bugs/Bug-647053-NonDeductible-VAT-Purch-Lines-Same-VAT-Identifier-v4

Conversation

@neeleshsinghal

@neeleshsinghal neeleshsinghal commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@neeleshsinghal
neeleshsinghal requested a review from a team August 21, 2026 14:36
@neeleshsinghal
neeleshsinghal requested review from a team as code owners August 21, 2026 14:36
@github-actions github-actions Bot added the SCM GitHub request for SCM area label Aug 21, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 21, 2026
Comment thread src/Layers/APAC/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/BE/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/CH/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/FI/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/GB/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/IT/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/NA/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/RU/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/W1/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/W1/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/APAC/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/BE/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/CH/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/DACH/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/ES/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/FI/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/GB/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/IT/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/NA/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/NL/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/NO/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/RU/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/W1/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/W1/BaseApp/Purchases/Document/PurchaseLine.Table.al
Comment thread src/Layers/W1/BaseApp/Purchases/Document/PurchaseLine.Table.al
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Web\ Services}$

This PR adds a new Error() path to the published Purchase Line validation contract without introducing a new API version. table 39 "Purchase Line" backs already-published routes such as the v2.0 purchaseOrderLine API, so the new CheckNonDedVATPctConsistencyForZeroLine() call can now turn existing POST/PATCH requests into new API error responses when another line on the document shares the VAT identifier but has a different "Non-Deductible VAT %". Published API behavior is part of the stable contract; keep existing routes behavior-compatible, or ship this rule behind a new API version instead of changing it in place.

Knowledge:

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 1

Recommendation: Request Changes

What this PR does

This PR fixes the Non-Deductible VAT purchase-line case where one line can be set to 0 while another line with the same VAT Identifier keeps a non-zero Non-Deductible VAT %. The existing validation already rejects the reverse order, and the new tests cover both entry orders. The rule itself is correct, but the new table-level call is placed outside the existing handled validation path.

Suggestions

S1 - Keep the check inside the existing validation
The new table-level call runs after OnBeforeCheckNonDeductibleVATPctIsAllowed, so subscribers that set IsHandled can still get this new error when the value is 0. Move the zero-value branch into NonDedVATImpl.CheckNonDeductibleVATPctIsAllowed after the existing IsHandled check, or add an equivalent handled event before this new error. Apply the same shape to the layer copies.

Risk assessment and necessity

Risk: This is purchase-line VAT validation, so a wrong change can block purchase documents and API writes for a financial field. The same check was added consistently to W1 and the regional BaseApp Purchase Line copies, and no new BaseApp publisher dependency was added; I verified the existing handled event in NonDeductibleVAT.Codeunit.al. CI still had some unit-test jobs running and two integration jobs marked failed without logs available from the in-progress run, so those results should be checked before merge.

Necessity: The scenario is valid: without the change, a document can mix 0 and non-zero Non-Deductible VAT % values under the same VAT Identifier depending on line entry order. The scope is targeted and the tests cover both order directions, but the fix should preserve the existing handled validation contract.


[AI-PR-REVIEW] version=1 promptVersion=2 system=github pr=10521 round=1 by=alexei-dobriansky at=2026-08-21T18:11:27Z lastSha=5794e0cf14cf2215060b59024d444a53150b1f16 reviewKey=da273117122186a6f1c90c3e24db6b21fa5624b9f3c8ffe342b8e5fdf2463867 suggestions=S1@44c8aee0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for three high-confidence issues:

S1 - Complete the setup-level fix. ADO bug #647365 explicitly requires preventing creation of the conflicting VAT Posting Setup configuration. This PR changes only Purchase Line validation. NonDedVATImpl.CheckVATPostingSetupChangeIsAllowed still exits for a Do Not Allow setup, so the reported non-deductible/normal setup pair with the same VAT Identifier can still be created. Enforce the invariant when the setup is created, as required by the work item.

S2 - Preserve the handled validation contract. The new zero-percent check runs directly from table 39 after NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed. A subscriber that handles OnBeforeCheckNonDeductibleVATPctIsAllowed(..., IsHandled) can suppress the existing check but still receives this new error. Move the zero-value branch into NonDedVATImpl.CheckNonDeductibleVATPctIsAllowed after the same IsHandled gate rather than duplicating the query, label, and error across 14 table copies.

S3 - Resolve the demonstrated test regression. Twenty-one LegacyTestsBucket1 jobs fail. The concrete failure is CombinedVATAmountLineForTwoPurchLineFirstNonDedVATSecondNormalVAT, which intentionally creates non-deductible and normal VAT lines sharing one VAT Identifier; the new validation now aborts that scenario. Since this work item intentionally changes the invariant, revise the existing W1/AU/IT/RU scenarios to assert the new behavior and add setup-level regression coverage. The PR status check is currently failed for this reason.

This is high-risk financial validation across all BaseApp layers. The two added tests cover both line-entry orders, but the implementation does not complete the linked acceptance scope, bypasses the established extensibility event, and breaks the existing suite.

@PredragMaricic Predrag Maricic (PredragMaricic) added Finance GitHub request for Finance area Ownership: Manual Preserve the manually selected team ownership and removed SCM GitHub request for SCM area labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Finance GitHub request for Finance area Ownership: Manual Preserve the manually selected team ownership

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants